package fhjoanneum.itm11.antesk.simplehack;

public class Level
{
	// Members -----------------------------------------------------------
	private Character pc;
	private int[] levels = {10, 20, 40, 80, 160, 320, 640, 1280};
	
	// Constructors ------------------------------------------------------
	Level(Character pc)
	{
		this.pc = pc;
	}
	
	// Methods ===========================================================
	
	// Checks if levelup is reached with the current exp value -----------
	public void checkExp()
	{
		for(int level = pc.getLevel()-1; level < levels.length; level++)
		{
			if(pc.getExp() >= levels[level]){
				levelUp();
			}
		}
	}
	
	// Levels the character up one level ---------------------------------
	public void levelUp()
	{
		pc.setLevel(pc.getLevel() + 1);
		System.out.println("Congratulations! You are now level " + 
				pc.getLevel());
	}
	
	// Adds exp to the character -----------------------------------------
	public void addExp(int value)
	{
		pc.setExp(pc.getExp() + value);
		checkExp();
	}
}
